﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using GpsTagger.Logic;
using System.IO;

namespace GpsTagger.Tests
{
    public partial class KMLParserTestFrm : Form
    {
        public KMLParserTestFrm()
        {
            InitializeComponent();
        }

        private void parseFile_Click(object sender, EventArgs e)
        {
            DialogResult dr = openKMLFile.ShowDialog();
            if (dr == DialogResult.OK)
            {
                string usedFileName = openKMLFile.FileName;
                openedFile.Text = usedFileName;
                using (StreamReader sr = new StreamReader(usedFileName))
                {
                    KMLFileContents.Text = sr.ReadToEnd();
                    sr.Close();
                }
                mapPoints.Items.Clear();
                Queue<MapPoint> tmpQueue = new Queue<MapPoint>();
                KMLParser kp = new KMLParser(usedFileName);
                kp.ParseFile();
                kp.GetPoints(tmpQueue);
                for (int i = 0; i < tmpQueue.Count; i++)
                {
                    mapPoints.Items.Add(tmpQueue.ElementAt(i).ToString());
                }
            }
        }
    }
}
